package com.sywb.chuangyebao.view;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sywb.chuangyebao.Constants;
import com.sywb.chuangyebao.R;

import org.bining.footstone.utils.SharedUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 账号安全
 */
public class UserSafeActivity extends ActionbarActivity {

    @BindView(R.id.tv_modify_pwd)
    TextView tvModifyPwd;
    @BindView(R.id.tv_mobile)
    TextView tvMobile;
    @BindView(R.id.iv_mobile_arrow)
    ImageView ivMobileArrow;
    @BindView(R.id.ll_mobile)
    LinearLayout llMobile;

    public String mobile;

    @Override
    public int getLayoutId(Bundle bundle) {
        return R.layout.activity_user_safe;
    }

    @Override
    public void initView(Bundle bundle) {
        super.initView(bundle);
        setTitle("账号安全");

        mobile = SharedUtils.getString(Constants.HTTP_SSO_BIND);
        tvMobile.setText(mobile);
        if (!TextUtils.isEmpty(mobile)) {
            ivMobileArrow.setVisibility(View.GONE);
        }
    }

    @OnClick({R.id.tv_modify_pwd, R.id.ll_mobile,})
    public void onClick(View view) {
        if (!isCanClick(view)) return;
        switch (view.getId()) {
            case R.id.tv_modify_pwd:
                advance(ForgetPwdActivity.class);
                break;
            case R.id.ll_mobile:
                if (TextUtils.isEmpty(tvMobile.getText().toString())) {
                    advance(BindMobileActivity.class);
                } else {
                    advance(BindMobileSuccessActivity.class, mobile);
                }
                break;
        }
    }

}
